import hashlib, time


class md5Enc(object):
    def get_sign(self, t):
        '''
        Examples:
        ${sign_md5} | Get Sign |${t_now}
        '''
        keyMd5 = hashlib.md5()
        api_key = "Guest-Bugmaster"
        sign_str = t + api_key
        sign_bytes_utf8 = sign_str.encode(encoding='utf-8')
        keyMd5.update(sign_bytes_utf8)
        keyMd5 = keyMd5.hexdigest()

        return keyMd5

    def get_time_stamp(self, t=''):
        timeArray = time.strptime(t, '%Y-%m-%d %H:%M:%S')
        timeStamp = int(time.mktime(timeArray))
        timeStamp_str = str(timeStamp)

        return timeStamp_str


md5 = md5Enc()
s = md5.get_time_stamp('2018-07-10 17:51:05')
print(s)
t = md5.get_sign('2014-06-12 20:00:58')
print(t)
